package cn.iocoder.yudao.module.brokerage.record.service;

import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.business.basic.dao.query.CoreQueryWrapper;
import cn.iocoder.yudao.framework.business.basic.service.impl.BaseService;
import cn.iocoder.yudao.module.brokerage.record.dao.BrokerageRecordMapper;
import cn.iocoder.yudao.module.brokerage.record.pojo.po.BrokerageRecordDO;
import cn.iocoder.yudao.module.brokerage.record.pojo.vo.AppBrokerageRecordQueryDTO;
import cn.iocoder.yudao.module.brokerage.record.pojo.vo.AppBrokerageRecordVO;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

/**
 * 分佣记录 Service 实现类
 *
 * @author 山野羡民
 */
@Slf4j
@Service
@Validated
public class AppBrokerageRecordServiceImpl extends BaseService<BrokerageRecordDO, AppBrokerageRecordVO, AppBrokerageRecordQueryDTO> implements AppBrokerageRecordService {
    @Resource
    private BrokerageRecordMapper brokerageRecordMapper;

    @Override
    protected BrokerageRecordMapper getInjectedMapper() {
        return brokerageRecordMapper;
    }

    @Nonnull
    @Override
    protected CoreQueryWrapper<BrokerageRecordDO> buildQueryWrapper(AppBrokerageRecordQueryDTO param) {
        CoreQueryWrapper<BrokerageRecordDO> wrapper = super.buildQueryWrapper(param);
        wrapper.eq(StrUtil.isNotBlank(param.getBizType()), "biz_type", param.getBizType());
        wrapper.eqIfPresent("status", param.getStatus());
        wrapper.orderByDesc("update_time");
        return wrapper;
    }

}